/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.isn.tratamiento.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author pool
 */
@Entity
@Table(name = "tipo_de_medicamento")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TipoDeMedicamento.findAll", query = "SELECT t FROM TipoDeMedicamento t"),
    @NamedQuery(name = "TipoDeMedicamento.findByCodTipmedi", query = "SELECT t FROM TipoDeMedicamento t WHERE t.codTipmedi = :codTipmedi"),
    @NamedQuery(name = "TipoDeMedicamento.findByDescTipmedi", query = "SELECT t FROM TipoDeMedicamento t WHERE t.descTipmedi = :descTipmedi")})
public class TipoDeMedicamento implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "Cod_Tipmedi", columnDefinition="CHAR(5) unsigned")
    private String codTipmedi;
    @Column(name = "Desc_Tipmedi")
    private String descTipmedi;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codTipmedi")
    private Collection<Medicamento> medicamentoCollection;

    public TipoDeMedicamento() {
    }

    public TipoDeMedicamento(String codTipmedi) {
        this.codTipmedi = codTipmedi;
    }

    public String getCodTipmedi() {
        return codTipmedi;
    }

    public void setCodTipmedi(String codTipmedi) {
        this.codTipmedi = codTipmedi;
    }

    public String getDescTipmedi() {
        return descTipmedi;
    }

    public void setDescTipmedi(String descTipmedi) {
        this.descTipmedi = descTipmedi;
    }

    @XmlTransient
    public Collection<Medicamento> getMedicamentoCollection() {
        return medicamentoCollection;
    }

    public void setMedicamentoCollection(Collection<Medicamento> medicamentoCollection) {
        this.medicamentoCollection = medicamentoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codTipmedi != null ? codTipmedi.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TipoDeMedicamento)) {
            return false;
        }
        TipoDeMedicamento other = (TipoDeMedicamento) object;
        if ((this.codTipmedi == null && other.codTipmedi != null) || (this.codTipmedi != null && !this.codTipmedi.equals(other.codTipmedi))) {
            return false;
        }
        return true;
    }
    
}
